//
//  M_Router.swift
//  TodayNews
//
//  Created by ZhangBo on 2019/6/17.
//  Copyright © 2019 ZhangBo. All rights reserved.
//

import UIKit

enum M_Router {
    case setting
    case login(LoginParam?)
    case userdetail(Int)
}

struct LoginParam {
    var account = ""
    var password = ""
    var successcallback: (() -> Void)?

    init(account: String = "", password: String = "", callback: (() -> Void)? = nil) {
        self.account = account
        self.password = password
        self.successcallback = callback
    }

    static var empty: LoginParam {
        return LoginParam.init(account: "", password: "", callback: nil)
    }
}

extension M_Router: RouterPathable {
    var any: AnyClass {
        switch self {
        case .login(_):
            return MoreLoginViewController.self
        case .userdetail(_):
            return UserDetailViewController.self
        default:
            return SettingViewController.self
        }
    }

    var params: RouterParameter? {
        switch self {
        case .login(let param):
            return ["param": param!]
        case .userdetail(let uid):
            return  ["param": uid]
        default:
            return nil
        }
    }

}
